package ua.cn.store.domain;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="Books")
@NamedQueries({
	@NamedQuery(name="Book.getBookByAuthor",query="select b from Book b where b.author like :b_author"),
	@NamedQuery(name="Book.getBookByName",query="select b from Book b where b.name like :b_name"),
	@NamedQuery(name="Book.getBookByGenre",query="select b from Book b where b.genre like :b_genre")	
})
public class Book extends Domain {
	
	private static final long serialVersionUID = 1L;

	private String author;
	
	@Enumerated
	private Genres genre;
	
	private String name;
	private int pageNum;
	private double prise;
	private List<Comment> comments = new ArrayList<Comment>();
	
	@OneToMany(mappedBy="book", cascade=CascadeType.ALL)
	public List<Comment> getComments() {
		return comments;
	}
	public void setComments(List<Comment> comments) {
		this.comments = comments;
	}
	@Column(name="author")	
	public String getAuthor() {
		return author;
	}
	public void setAuthor(String author) {
		this.author = author;
	}
	public Genres getGenre() {
		return genre;
	}
	public void setGenre(Genres genre) {
		this.genre = genre;
	}
	
	@Column(name="name")	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@Column(name="pages")	
	public int getPageNum() {
		return pageNum;
	}
	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}
	
	@Column(name="price")	
	public double getPrise() {
		return prise;
	}
	public void setPrise(double prise) {
		this.prise = prise;
	}
	
		
		
}
